﻿using CommonLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YouErYuanBLL;

namespace YouErYuanManage.Controllers
{
    public class loginReportController : Controller
    {
       
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns></returns>
        [YouErYuanManage.Filter.IsLogin]
        public string loginReport()
        {
            loginReportBLL ckbll = new loginReportBLL();
            int pageIndex = 0;
            int pageSize = 0;
            try
            {
                pageIndex = Convert.ToInt32(Request["pageIndex"]);
                pageSize = Convert.ToInt32(Request["pageSize"]);
            }
            catch (Exception)
            {
                pageIndex = 1;
                pageSize = 10;
            }
            //开始时间
            string startTime = Request["stime"] + "";
            //结束时间
            string endTime = Request["etime"] + "";
            //版本
            string vision = Request["vision"] + "";
            int total = 0;
            object dt = ckbll.loginLogs(pageIndex, pageSize, startTime, endTime, vision, out total);
            int pageCount = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;//总页数
            var data = new
            {
                pageIndex = pageIndex,
                pageCount = pageCount,
                list = dt,
                total = total
            };
            return CommonMethod.FormatJsonObj("", data);
        }
        /// <summary>
        /// 每个幼儿园的登录情况
        /// </summary>
        /// <returns></returns>
        public string loginInfo()
        {
            loginReportBLL ckbll = new loginReportBLL();
            //开始时间
            string startTime = Request["stime"] + "";
            //结束时间
            string endTime = Request["etime"] + "";
            //幼儿园id
            string schoolid = Request["schoolid"] + "";
            //版本
            string vision = Request["vision"] + "";
            object data = ckbll.loginInfo(schoolid, startTime, endTime,vision);
            var obj = new {
                list = data
            };
            return CommonMethod.FormatJsonObj("", obj);
        }
    }
}